<?php

namespace App\Admin\Controllers\Commodity;

use Encore\Admin\Form;
use Encore\Admin\Grid;
use Encore\Admin\Facades\Admin;
use Encore\Admin\Layout\Content;
use Encore\Admin\Layout\Row;
use Encore\Admin\Layout\Column;
use App\Http\Controllers\Controller;
use Encore\Admin\Controllers\ModelForm;
use Illuminate\Contracts\Routing\UrlGenerator;
use App\Model\Commodity_info;
use App\Model\Commodity;
use App\Model\Commodity_classify;

class InfoController extends Controller
{
    use ModelForm;
    protected $commodity;
    protected $classify;
    protected $info;
    function __construct(Commodity_classify $classify,Commodity $commodity,Commodity_info $info)
    {
        $this->commodity = $commodity;
        $this->classify = $classify;
        $this->info = $info;
    }

    private $nav = array(
        'one' => array(
            'name' => '商品信息',
            'url' => '/admin/commodity/info'
        ),
        'two' => array(
            'name' => '商品信息添加',
            'url' => '/admin/commodity/add_info'
        ),
        'three' => array(
            'name' => '商品信息编辑',
            'url' => '/admin/commodity/edit_commodity'
        ),
    );
    /**
     * Index interface.
     *
     * @return Content
     */
    public function index()
    {
        return Admin::content(function (Content $content) {
            $content->header('商品');
            $content->description('商品信息');
            $content->breadcrumb(
                ['text' => '商品', 'url' => '/commodity/'],
                ['text' => '商品信息' ,'url'=> 'commodity/info']
            );
//            $info = $this->info->get_info();
            $content->body(view("Admin.Commodity.Info.index",['nav' => $this->nav,'classify' => $this->classify->get_all_classify()]));
        });
    }
}
